﻿using System.Modules.Contracts.DTO;
using System.Modules.SharePoint.Contracts.Interfaces;
using System.Reflection;
using System.Text;

namespace System.Modules.SharePoint.Contracts.DTO
{
    /// <summary>
    /// public Guid UniqueId { get; set; }
    /// public string Title { get; set; }
    /// public int ID { get; set; }
    /// </summary>
    [Serializable]
    public class BaseListItem : Initiator, IBaseListItem
    {
        /// <summary>
        /// Field Names
        /// </summary>
        public enum FieldNames
        {
            /// <summary>
            /// UniqueId
            /// </summary>
            UniqueId,
            /// <summary>
            /// Title
            /// </summary>
            Title,
            /// <summary>
            /// ID
            /// </summary>
            ID,
            /// <summary>
            /// Author
            /// </summary>
            Author,
            /// <summary>
            /// Editor
            /// </summary>
            Editor,
            /// <summary>
            /// Content Type
            /// </summary>
            ContentType
        }
        /// <summary>
        /// UniqueId | Guid
        /// </summary>
        public Updatable<Guid> UniqueId { get; set; }
        /// <summary>
        /// Title | string
        /// </summary>
        public Updatable<string> Title { get; set; }
        /// <summary>
        /// ID | Integer
        /// </summary>
        public Updatable<int> ID { get; set; }

        /// <summary>
        /// Created | DateTime
        /// </summary>
        public Updatable<DateTime> Created { get; set; }

        /// <summary>
        /// Modified | DateTime
        /// </summary>
        public Updatable<DateTime> Modified { get; set; }

        /// <summary>
        /// ContentType | String | Calculated
        /// </summary>
        public String ContentType { get; set; }

        /// <summary>
        /// Gets Item Properties Place Holders
        /// </summary>
        public String FormatedItemPropertiesPlaceHolders
        {
            get
            {
                var builder = new StringBuilder();
                var type = GetType();
                var properties = type.GetProperties();
                foreach (var property in properties)
                {
                    builder.AppendFormat("{1}: {{{0}.{1}}}", type.Name, property.Name).Append("<Br/>");
                }
                return builder.ToString();
            }
        }
    }
}